<template>
  <div class="a">
    <van-nav-bar
      title="预约洗衣"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="b">
      <div>
        <span>联系人:</span
        ><input type="text" placeholder="请输入名字" v-model="name" />
      </div>
      <div>
        <span>手机号码:</span
        ><input type="text" placeholder="请输入电话" v-model="phone" />
      </div>
      <div>
        <span>详细地址:</span
        ><input type="text" placeholder="请输入地址" v-model="address" />
      </div>
       <div>
        设置为默认地址
         <van-switch v-model="checked" @change="turnOff" />
        </div>
      <div><button @click="address1">保存</button></div>
      <div><button @click="go">查看全部地址</button></div>
    </div>
  </div>
</template>
<script>
import { Toast } from "vant";
import { fapi1 } from "@/assets/js/farmapi.js";
export default {
  data() {
    return {
      name: null,
      phone: null,
      address: null,
      moren:1,
      checked:false,
    };
  },
  created() {},

  methods: {
    address1() {
      let data = {
        name: this.name,
        phone: this.phone,
        address: this.address,
        moren: this.moren,
        userId: sessionStorage.getItem("islogin"),
      };

      fapi1("api/address", data, "post").then((res) => {
        console.log(res);
      });
    },
    go() {
      this.$router.push("/addressAll");
    },
    onClickLeft() {
    this.$router.push('/');
  },turnOff(v){
            console.log(v)
            if(v ==true){
                this.moren =1
            }else{
                this.moren=0
            }
        },
  }
  
};
</script>
<style lang="less" scoped>
input {
  width: 65%;
  margin: 60px 40px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 30px;
}
button {
  background-color: #03a19c;
  color: #fff;
  width: 90%;
  height: 80px;
  margin: 40px 5%;
  font-size: 40px;
  border-radius: 80px;
}
span {
  display: inline-block;
  font-size: 30px;
  font-weight: 400;
  width: 150px;
}
.b {
  padding: 0px 40px;
}
</style>